#include "customsize.h"

CustomSize::CustomSize(QMainWindow *parent) : QDialog(parent)
{
    this->setWindowFlags(windowFlags()&~Qt::WindowCloseButtonHint&~Qt::WindowContextHelpButtonHint);
    this->setWindowTitle("自定义图像");
    this->setFixedSize(270,120);
    widthLabel = new QLabel(this);
    heightLabel = new QLabel(this);
    widthLabel->resize(100,30);
    widthLabel->setText("宽度：");
    widthLabel->setAlignment(Qt::AlignCenter);
    heightLabel->resize(100,30);
    heightLabel->setText("高度：");
    widthLabel->move(0,10);
    heightLabel->move(0,40);
    heightLabel->setAlignment(Qt::AlignCenter);

    widthBox = new QSpinBox(this);
    widthBox->resize(150,30);
    widthBox->setRange(1,500);
    heightBox = new QSpinBox(this);
    heightBox->setRange(1,500);
    heightBox->resize(150,30);
    widthBox->move(100,0);
    heightBox->move(100,40);

    changeSizeButton = new QPushButton(this);
    connect(changeSizeButton,SIGNAL(clicked(bool)),this,SLOT(changeSize()));
    changeSizeButton->resize(100,30);
    changeSizeButton->move(20,90);
    changeSizeButton->setText("确定");

    cancelButton = new QPushButton(this);
    connect(cancelButton,SIGNAL(clicked(bool)),this,SLOT(close()));
    cancelButton->setText("取消");
    cancelButton->move(150,90);
    cancelButton->resize(100,30);
}
void CustomSize::changeSize()
{
    changed = true;
    newWidth = (widthBox->text()).toInt();
    newHeight = (heightBox->text()).toInt();
    qDebug()<<"宽度："<<newWidth<<"高度"<<newHeight;
    this->close();
}
